﻿using BasicInformation.Domain;
using BasicInformation.ReadAPI.Application.Command.LineCommand;
using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using PublicCommon;

namespace BasicInformation.ReadAPI.Controllers
{
    /// <summary>
    /// 线路查询控制器
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LineInfoController : ControllerBase
    {
        private readonly IMediator mediator;

        public LineInfoController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 获取线路信息
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<List<LineSelect>> GetLineRoute([FromQuery]LineRouteListCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 线路列表
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<PageResult<Line>> GetLineList([FromQuery]LineListCommand command)
        {
            return await mediator.Send(command);
        }

        /// <summary>
        /// 根据线路Id找到线路实体
        /// </summary>
        /// <param name="command"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<Line> GetLineInfo([FromQuery]LineInfoCommand command)
        {
            return await mediator.Send(command);
        }

    }
}
